package com.suixinsanren.design.responsibilitychain.demo01;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class StGenderCheck extends AbsCheckStudent {

    private final String MAN = "男";
    private final String WOMAN = "女";

    //获取学生年龄不符合条件的学生对象
    @Override
    public List<Student> checkStudent(List<Student> studentList) {
        List<Student> stGenderIsNoOk = studentList.stream().filter(stu -> {
            String gender = stu.getGender();
            return Objects.isNull(gender) || !(MAN.equals(gender) || WOMAN.equals(gender));
        }).collect(Collectors.toList());
        System.out.println("性别校验没有通过的数据： " + stGenderIsNoOk);
        studentList.removeAll(stGenderIsNoOk);
        System.out.println("性别校验通过的数据： " + studentList);
        return studentList;
    }
}
